Add a short section about path dependencies
authorAlex Crichton <alex@alexcrichton.com>
Wed, 14 Jan 2015 04:04:43 +0000 (20:04 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Fri, 16 Jan 2015 04:11:54 +0000 (20:11 -0800)
Closes #640

src/bin/build.rs
src/doc/guide.md

index ec1c02e8573de23cdcc2f5196e9965a886564bb6..c6d35849b4bb5670b9aa0c485aeeb7c109f9485a 100644 (file)
@@ -43,8 +43,8 @@ current package is built. For more information on SPEC and its format, see the
 `cargo help pkgid` command.
 
 Compilation can be configured via the use of profiles which are configured in
-the manifest. The default profile for this command is `dev`, but passing the
---release flag will use the `release` profile instead.
+the manifest. The default profile for this command is `dev`, but passing
+the --release flag will use the `release` profile instead.
 ";
 
 pub fn execute(options: Options, shell: &mut MultiShell) -> CliResult<Option<()>> {
index 027b41c51b6c8e768599256e2682f70a8e1af442..f44c83684a385d5f28619ed4b7188b0da979f55d 100644 (file)
@@ -392,6 +392,34 @@ test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured
 Of course, if your project has tests, you'll see more output, with the
 correct number of tests.
 
+# Path Dependencies
+
+Over time our `hello_world` project has grown significantly in size! It's gotten
+to the point that we probably want to split out a separate crate for others to
+use. To do this Cargo supports **path dependencies** which are typically
+sub-crates that live within one repository. Let's start off by making a new
+crate inside of our `hello_world` project:
+
+```shell
+# inside of hello_world/
+$ cargo new hello_utils
+```
+
+This will create a new folder `hello_utils` inside of which a `Cargo.toml` and
+`src` folder are ready to be configured. In order to tell Cargo about this, open
+up `hello_world/Cargo.toml` and add these lines:
+
+```toml
+[dependencies.hello_utils]
+path = "hello_utils"
+```
+
+This tells Cargo that we depend on a crate called `hello_utils` which is found
+in the `hello_utils` folder (relative to the `Cargo.toml` it's written in).
+
+And that's it! The next `cargo build` will automatically build `hello_utils` and
+all of its own dependencies, and others can also start using the crate as well.
+
 ## Travis-CI
 
 To test your project on Travis-CI, here is a sample `.travis.yml` file: